package com.hsd.netty.client.strategy;

import com.hsd.netty.client.cache.OverallStaticCache;
import com.hsd.netty.client.common.NettyMessage;
import com.hsd.netty.client.context.ContextData;
import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author s.he
 * on 2020/6/8
 */
public class ResponseStrategy extends NettyMessageAdapter {
    private static final Logger logger = LoggerFactory.getLogger(ResponseStrategy.class);

    @Override
    public void handleServerResponse(ChannelHandlerContext ctx, Object msg) {
        NettyMessage nettyMessage = (NettyMessage)msg;
        logger.info("【接口调用响应】请求返回的数据为:{}, 请求流水号为:{}", nettyMessage.getBody(), nettyMessage.getNettyHeader().getRequestNumber());
        OverallStaticCache.put(nettyMessage.getNettyHeader().getRequestNumber(), nettyMessage.getBody());
    }
}
